#include "debug.hpp"
#include "lge2d.hpp"
#include "application.hpp"

#ifdef _DEBUG
extern void RunTests();
#endif

int main(int argc, char *argv[])
{
	lge2d::Initialize();
	lge2d::log->Info("start application");

#ifdef _DEBUG
	debug_init();
	lge2d::log->Info("init debug");

	lge2d::log->Info("run tests");
	RunTests();
#endif

	try
	{
		lge2d::Application App;
		App.Initialize();
		App.StartGameLoop();
	} catch (std::runtime_error& e)
	{
		lge2d::log->Error(e.what());
		debug_message_box("error", e.what());
	}

	lge2d::log->Info("destroy application");

	lge2d::Destroy();
	return EXIT_SUCCESS;
}
